package dormouse.bookmarks;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * This class contains the basic logic for a Bookmark POJO.
 */
public class Bookmark {

	/** The URL to be bookmarked. */
	private String url = null;
	
	/** The name of the bookmark. */
	private String name = null;
	
	/** The description of the bookmark. */
	private String description = null;
	
	/** The notes for the bookmark. */
	private String notes = null;
	
	/** Indicates whether the bookmark is shareable. */
	private boolean shareable = false;
	
	/** A list of tags associated with the bookmark, used to classify the bookmark.*/
	private List<String> tags = new ArrayList<String>();

	/**
	 * Constructor.
	 */
	public Bookmark() {
	}

	/**
	 * Constructor
	 * 
	 * @param name
	 *            The name of the bookmark. This will appear in a tree node.
	 * @param url
	 *            The URL of the bookmark.
	 * @param description
	 *            The description of the bookmark.
	 * @param notes
	 *            Any notes associated with the bookmark.
	 * @param shareable
	 *            Indicates whether or not the bookmark is shareable.
	 * @param tags
	 *            A comma-delimited list of tags associated with the bookmark.
	 */
	public Bookmark(String name, String url, String description, String notes,
			boolean shareable, List<String> tags) {
		this.name = name;
		this.url = url;
		this.description = description;
		this.notes = notes;
		this.shareable = shareable;

	}

	/**
	 * Constructor
	 * 
	 * @param name
	 *            The name of the bookmark (usually displayed on the desktop).
	 * @param url
	 *            The URL for the bookmark
	 */
	public Bookmark(String name, String url) {
		this.name = name;
		this.url = url;
	}


	

	/**
	 * Gets the URL of the bookmark.
	 * @return the URL of the bookmark.
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * Sets the URL of the bookmark.
	 * @param url the URL of the bookmark.
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * Gets the name of the bookmark.
	 * @return the name of the bookmark.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name of the bookmark.
	 * @param name the name of the bookmark.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the description of the bookmark.
	 * @return the description of the bookmark.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Sets the description of the bookmark.
	 * @param description the description of the bookmark.
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Gets the notes of the bookmark.
	 * @return the notes of the bookmark.
	 */
	public String getNotes() {
		return notes;
	}

	/**
	 * Sets the notes of the bookmark.
	 * @param notes the notes of the bookmark.
	 */
	public void setNotes(String notes) {
		this.notes = notes;
	}

	/**
	 * Indicates that the bookmark is shareable.
	 * @return
	 */
	public boolean isShareable() {
		return shareable;
	}

	/**
	 * Sets whether or not the bookmark is shareable.
	 * @param shareable
	 */
	public void setShareable(boolean shareable) {
		this.shareable = shareable;
	}

	/**
	 * Sets the tags for the bookmark.
	 * @param tags  a list of tags for the bookmark.
	 */
	public void setTags(List<String> tags) {
		this.tags = tags;
	}

	/**
	 * Sets the tags for the bookmark.
	 * @param tags a comma-delimited list of tags for the bookmark.
	 */
	public void setTags(String tags) {
		String[] tagArray = tags.split(",");
		for (int i = 0; i < tagArray.length; i++) {
			tagArray[i] = tagArray[i].trim();
		}
		this.tags = Arrays.asList(tagArray);
	}

	/**
	 * Adds a tag for the bookmark
	 * @param tag the new tag.
	 */
	public void addTag(String tag) {
		this.tags.add(tag);
	}





}
